﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace _03_InsertLineNumber
{
    class InsertLineNums
    {
        static void Main(string[] args)
        {
            StreamReader reader = new StreamReader("text.txt");
            StringBuilder resultText = new StringBuilder();
            using (reader)
            {
                int lineNum = 1;
                string line = reader.ReadLine();
                while (line != null)
                {
                    resultText.Append(lineNum);
                    resultText.Append(" ");
                    resultText.Append(line);
                    resultText.Append("\r\n");
                    line = reader.ReadLine();
                    lineNum++;
                }
            }
            StreamWriter outputWriter = new StreamWriter("result.txt");
            using (outputWriter)
            {
                outputWriter.Write(resultText.ToString());
            }
        }
    }
}
